import 'package:flutter/material.dart';

class HomeMenusView extends StatefulWidget {
  final List dataSource;

  const HomeMenusView({Key key, this.dataSource}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _HomeMenusViewState();
  }
}

class _HomeMenusViewState extends State<HomeMenusView> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return SliverGrid.count(
      crossAxisCount: 5,
      crossAxisSpacing: 10,
      mainAxisSpacing: 10,
      children: [
        MenuItem(),
        MenuItem(),
        MenuItem(),
        MenuItem(),
        MenuItem(),
        MenuItem(),
        MenuItem(),
        MenuItem(),
      ],
    );
  }
}

class MenuItem extends StatelessWidget {
  final Object data;
  final Function onPress;
  const MenuItem({Key key, this.data, this.onPress}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GestureDetector(
      onTap: onPress,
      child: SizedBox(
         child: Column(
          mainAxisSize: MainAxisSize.max,
          children: [
            Image.asset(
              'assets/images/funcs/bsbx.png',
              width: 45,
            ),
            Expanded(
              child: Padding(
                padding: EdgeInsets.only(top: 5),
                child: Text(
                  '报事报修',
                  style: TextStyle(fontSize: 13, color: Color(0XFF333333)),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
